<template>
  <div class="app-container">
    <el-form id="test1" :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
      label-width="120px">

      <el-form-item label="车号：" prop="tpname" width="240px">
        <el-input v-model="queryParams.tpname" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="称重编号：" prop="czbh">
        <el-input v-model="queryParams.czbh" width="240px" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="供应商名：" prop="rzname">
        <el-input v-model="queryParams.rzname" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="合同号：" prop="xlhbs">
        <el-input v-model="queryParams.xlhbs" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="化验打印次数：" prop="sfname">
        <el-input v-model="queryParams.sfname" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="退车：" prop="yijian">
        <el-select v-model="queryParams.yijian" placeholder="请选择 " clearable @keyup.enter.native="handleQuery">
          <el-option label="正常" value="正常">正常</el-option>
          <el-option label="退车" value="退车">退车</el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="化验时间：" prop="hysj">
        <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
          range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['system:huayan:add']"
          >新增</el-button>
        </el-col> -->
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
          @click="handleUpdate">打印</el-button>
      </el-col>

      <!-- <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['system:huayan:remove']"
          >删除</el-button>
        </el-col> -->

      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="huayanList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label=" " align="center" prop="cysj" />
        <el-table-column label=" " align="center" prop="ymqybsm" /> -->
      <el-table-column label="称重编号" width="150" align="center" prop="czbh" />
      <!-- <el-table-column label="" align="center" prop="ypks" />
        <el-table-column label=" " align="center" prop="zzks" /> -->
      <el-table-column label="车号" width="110" align="center" prop="tbGuozhong.chehao" />
      <el-table-column label="供应商名" align="center" prop="tbGuozhong.gysdm" />
      <el-table-column label="合同号" align="center" prop="tbGuozhong.jshth" />
      <el-table-column label="杂质" align="center" prop="zz" />
      <el-table-column label="杂质扣" align="center" prop="zzk" />
      <el-table-column label="水分" align="center" prop="sf" />
      <el-table-column label="水扣" align="center" prop="sfk" />
      <el-table-column label="不完善" align="center" prop="bwsl" />
      <el-table-column label="不完善扣" align="center" prop="bwslk" />
      <el-table-column label="总扣" align="center" prop="zk" />
      <el-table-column label="化验人员" align="center" prop="czry" />
      <el-table-column label="容重数量" align="center" prop="rzsl" />
      <el-table-column label="容重等级" align="center" prop="rzdj" />
      <el-table-column label="结算单价" align="center" prop="tbGuozhong.jsdj" />
      <el-table-column label="退车" align="center" prop="tbGuozhong.yj" />
      <el-table-column label="化验单打印次数" align="center" prop="tbGuozhong.hyddy" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">打印</el-button>
          <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:huayan:remove']">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <el-dialog id="NbAllPage" width="730px" :visible.sync="open" append-to-body>
      <el-row id="qwerq" width="720px">
        <el-col style="border: 2px solid #000000; padding: 10px;">
          <div class="qrcode" ref="qrCodeUrl" id="erweima"></div>

          <div id="div1">
            <div id="imagediv">
              <img id="myImage" src="@/assets/images/yumizhang.png" alt="">
              <div id="p1" style="text-align: center;">{{ shijian }}</div>
            </div>
            <div id="imagediv2">
              <img id="myImage" src="@/assets/images/yumizhang.png" alt="">
              <div id="p1" style="text-align: center;">{{ shijian }}</div>
            </div>

            <h1 style="text-align: center;">玉米检验报告单</h1>
            <div class="zitidiv">
              <el-descriptions :column="3" size="mini">
                <el-descriptions-item label="化验时间" label-class-name="my-label" content-class-name="my-content">{{
                  form.hysj
                  }}</el-descriptions-item>
                <el-descriptions-item label="地磅单号">{{ form.czbh }}</el-descriptions-item>
              </el-descriptions>
              <el-descriptions :column="5" size="mini" border>
                <el-descriptions-item label="序列号" label-class-name="my-label" content-class-name="my-content"
                  :span="2">{{
                    form.ymqybsm }}</el-descriptions-item>
                <el-descriptions-item label="车号" :span="2">{{ form.tbGuozhong.chehao }}</el-descriptions-item>
                <el-descriptions-item label="打印次数">{{ form.tbGuozhong.hyddy }}</el-descriptions-item>
                <el-descriptions-item label="供应商" :span="2">
                  {{ form.tbGuozhong.gysdm }}
                </el-descriptions-item>
                <el-descriptions-item label="联系地址" :span="3">{{ form.tbGuozhong.zczm }}</el-descriptions-item>
                <el-descriptions-item label="水分%">
                  {{ form.sf }}
                </el-descriptions-item>
                <el-descriptions-item label="杂质%">
                  {{ form.zz }}
                </el-descriptions-item>
                <el-descriptions-item label="不完善粒%">
                  {{ form.bwsl }}
                </el-descriptions-item>
                <el-descriptions-item label="生霉粒%">
                  {{ form.mbl }}
                </el-descriptions-item>
                <el-descriptions-item label="白糯性玉米%">
                  {{ form.bnl }}
                </el-descriptions-item>
                <el-descriptions-item label="水分扣重%">
                  {{ form.sfk }}
                </el-descriptions-item>
                <el-descriptions-item label="杂质扣重%">
                  {{ form.zzk }}
                </el-descriptions-item>
                <el-descriptions-item label="不完善粒扣重%">
                  {{ form.bwslk }}
                </el-descriptions-item>
                <el-descriptions-item label="生霉粒扣重%">
                  {{ form.mblk }}
                </el-descriptions-item>
                <el-descriptions-item label="白糯性玉米扣重%">
                  {{ form.bnlk }}
                </el-descriptions-item>
                <el-descriptions-item label="总扣重%">
                  {{ form.zk }}
                </el-descriptions-item>
                <el-descriptions-item label="加扣%">
                  {{ form.tbGuozhong.hyjfkx }}
                </el-descriptions-item>
                <el-descriptions-item label="容重数量%">
                  {{ form.rzsl }}
                </el-descriptions-item>
                <el-descriptions-item label="容重等级%">
                  {{ form.rzdj }}
                </el-descriptions-item>
                <el-descriptions-item label="色泽气味%">
                  {{ form.szqw }}
                </el-descriptions-item>
              </el-descriptions>
              <el-descriptions :column="10" :colon="false">
                <el-descriptions-item label="制单人" span="2">
                  {{ username }}
                </el-descriptions-item>
                <el-descriptions-item label="卸车部门" span="2">
                  {{ form.tbGuozhong.xcbm }}
                </el-descriptions-item>
                <el-descriptions-item label="仓库编号" span="3">
                  {{ form.tbGuozhong.ckbh }}{{ form.tbGuozhong.ckmc }}
                </el-descriptions-item>
                <el-descriptions-item label="出厂时间" span="3">
                  {{ form.tbGuozhong.pzsj }}
                </el-descriptions-item>
              </el-descriptions>
            </div>
            <div style="height:230px;">
              <el-row :gutter="20">
                <el-col :span="11">
                  <div class="grid-content bg-purple div11">
                    <!-- <img :src="form.zp1"  class="img22" alt=""> -->
                    <img src="@/assets/images/20250120000622965.png" class="img22" alt="">
                  </div>
                </el-col>
                <el-col :span="2">
                  <div class="grid-content bg-purple div11">
                    <h4>严</h4>
                    <h4>防</h4>
                    <h4>车</h4>
                    <h4>辆</h4>
                    <h4>厂</h4>
                    <h4>区</h4>
                    <h4>内</h4>
                    <h4>套</h4>
                    <h4>牌</h4>
                    <h4>换</h4>
                    <h4>牌</h4>
                  </div>
                </el-col>
                <el-col :span="11">
                  <div class="grid-content bg-purple div11">
                    <!-- <img :src="form.zp2" class="img22" alt=""> -->
                    <img src="@/assets/images/20250120000622965.png" class="img22" alt="">
                  </div>
                </el-col>
              </el-row>
            </div>
            <h4 style="text-align: left">注意：此化验单以及其他要求的客户信息，到过磅回皮。当天换票，过期作废。</h4>
            <el-divider style="border-top: 1px dashed #dcdfe6;"></el-divider>
            <h1 style="text-align: center;">玉米检验报告单（存根）</h1>
            <div class="zitidiv">
              <el-descriptions :column="3" size="mini">
                <el-descriptions-item label="化验时间" label-class-name="my-label" content-class-name="my-content">{{
                  form.hysj
                  }}</el-descriptions-item>
                <el-descriptions-item label="地磅单号">{{ form.czbh }}</el-descriptions-item>
              </el-descriptions>
              <el-descriptions :column="5" size="mini" border>
                <el-descriptions-item label="序列号" label-class-name="my-label" content-class-name="my-content"
                  :span="2">{{
                    form.ymqybsm }}</el-descriptions-item>
                <el-descriptions-item label="车号" :span="2">{{ form.tbGuozhong.chehao }}</el-descriptions-item>
                <el-descriptions-item label="打印次数">{{ form.tbGuozhong.hyddy }}</el-descriptions-item>
                <el-descriptions-item label="供应商" :span="2">
                  {{ form.tbGuozhong.gysdm }}
                </el-descriptions-item>
                <el-descriptions-item label="联系地址" :span="3">{{ form.tbGuozhong.zczm }}</el-descriptions-item>
                <el-descriptions-item label="水分%">
                  {{ form.sf }}
                </el-descriptions-item>
                <el-descriptions-item label="杂质%">
                  {{ form.zz }}
                </el-descriptions-item>
                <el-descriptions-item label="不完善粒%">
                  {{ form.bwsl }}
                </el-descriptions-item>
                <el-descriptions-item label="生霉粒%">
                  {{ form.mbl }}
                </el-descriptions-item>
                <el-descriptions-item label="白糯性玉米%">
                  {{ form.bnl }}
                </el-descriptions-item>
                <el-descriptions-item label="水分扣重%">
                  {{ form.sfk }}
                </el-descriptions-item>
                <el-descriptions-item label="杂质扣重%">
                  {{ form.zzk }}
                </el-descriptions-item>
                <el-descriptions-item label="不完善粒扣重%">
                  {{ form.bwslk }}
                </el-descriptions-item>
                <el-descriptions-item label="生霉粒扣重%">
                  {{ form.mblk }}
                </el-descriptions-item>
                <el-descriptions-item label="白糯性玉米扣重%">
                  {{ form.bnlk }}
                </el-descriptions-item>
                <el-descriptions-item label="总扣重%">
                  {{ form.zk }}
                </el-descriptions-item>
                <el-descriptions-item label="加扣%">
                  {{ form.tbGuozhong.hyjfkx }}
                </el-descriptions-item>
                <el-descriptions-item label="容重数量%">
                  {{ form.rzsl }}
                </el-descriptions-item>
                <el-descriptions-item label="容重等级%">
                  {{ form.rzdj }}
                </el-descriptions-item>
                <el-descriptions-item label="色泽气味%">
                  {{ form.szqw }}
                </el-descriptions-item>
              </el-descriptions>
              <el-descriptions :column="10" :colon="false">
                <el-descriptions-item label="制单人" span="2">
                  {{ username }}
                </el-descriptions-item>
                <el-descriptions-item label="卸车部门" span="2">
                  {{ form.tbGuozhong.xcbm }}
                </el-descriptions-item>
                <el-descriptions-item label="仓库编号" span="3">
                  {{ form.tbGuozhong.ckbh }}{{ form.tbGuozhong.ckmc }}
                </el-descriptions-item>
                <el-descriptions-item label="出厂时间" span="3">
                  {{ form.tbGuozhong.pzsj }}
                </el-descriptions-item>
              </el-descriptions>
            </div>
          </div>
        </el-col>
      </el-row>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" class="common-button" v-print="printObject">打印html</el-button>
      </div>

    </el-dialog>


  </div>
</template>
<style>
/* el-divider 修改高度&虚线效果 */
.el-divider--horizontal {
  margin: 1px 0;
  background: 0 0;
  border-top: 3px dashed #000000;
}

.el-descriptions--medium.is-bordered .el-descriptions-item__cell {
  padding: 10px;
  color: #000000;
}

.el-descriptions--mini.is-bordered .el-descriptions-item__cell {
  padding: 6px 10px;
  color: #000;
}

.el-descriptions__body {
  color: #000000;
  background-color: #FFFFFF;
}



.div11 {
  /* background-color: rgba(0, 255, 38, 0.5); */
  height: 230px;
}

.img22 {
  width: 100%;
  height: auto;
  z-index: -999;
}

h1,
h3 {
  /* font-family: 'Arial', sans-serif; */
  /* 设置字体 */
  /* font-size: 36px; */
  /* 设置字体大小 */
  color: #000000;
  /* 设置字体颜色 */
  /* text-align: center; */
  /* 设置文本居中对齐 */
  /* line-height: 1.5; */
  /* 设置行高 */
  /* margin-top: 20px; */
  /* 设置顶部外边距 */
  /* margin-bottom: 20px; */
  /* 设置底部外边距 */
  font-weight: bold;
  /* 设置字体加粗 */
  /* text-transform: uppercase; */
  /* 将文本转换为大写字母 */
  /* letter-spacing: 2px; */
  /* 设置字母间距 */
}

h4 {
  line-height: 0;
  margin-top: 0px;
  text-align: center;
  font-weight: bold;
}

/*去除页眉页脚*/
@page {
  size: auto;
  margin: 10mm;
}

@page {
  margin-bottom: 0mm;
}


#imagediv {
  position: absolute;
  top: 240px;
  left: 530px;
  width: 25%;
  height: auto;
  color: #000;
  z-index: 1;

}

#imagediv2 {
  position: absolute;
  top: 510px;
  left: 530px;
  width: 25%;
  height: auto;
  color: #000;

}

#myImage {
  position: absolute;
  mix-blend-mode: multiply;
  width: 100%;
  height: auto;
}

#erweima {
  position: absolute;
  right: 10px;
}


#p1 {
  position: relative;
  font-size: 14px;
  top: 48px;
}

/* html {
  background-color: #FFFFFF;
  margin: 0;
}

body {
  border: solid 1px blue;
  margin: 10mm 15mm 10mm 15mm;
} */
</style>


<script>
import { listHuayan, getHuayan, delHuayan, addHuayan, updateHuayan, UpdateHuayanDycs } from "@/api/system/huayan";
import test from '@/views/Fdongbei/huayan/test.vue'
import QRCode from 'qrcodejs2'
export default {

  name: "Huayan",
  components: {
    test
  },
  data() {
    const today = new Date();
    const twoWeeksAgo = new Date(today);
    twoWeeksAgo.setDate(today.getDate() - 14);

    const formatDate = (date) => {
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0');
      const day = String(date.getDate()).padStart(2, '0');
      return `${year}-${month}-${day}`;
    };
    return {
      // 遮罩层
      loading: true,
      text: "",
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedTbGuozhong: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 化验--》表格数据
      huayanList: [],
      // tb表格数据
      tbGuozhongList: [],
      // 日期范围
      dateRange: [formatDate(twoWeeksAgo), formatDate(today)],
      // 弹出层标题
      title: "",
      abab: "测试abab",
      // 是否显示弹出层
      open: false,
      username: "",
      shijian: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cysj: null,
        ymqybsm: null,
        czbh: null,
        ypks: null,
        zzks: null,
        zz: null,
        zzk: null,
        sf: null,
        sfk: null,
        bwsls: null,
        bwsl: null,
        bwslk: null,
        mbls: null,
        mbl: null,
        mblk: null,
        bnls: null,
        bnl: null,
        bnlk: null,
        szqw: null,
        zk: null,
        hysj: null,
        zt: null,
        hys: null,
        czry: null,
        hwmc: null,
        bz: null,
        rzsl: null,
        rzdj: null,
        zp1: null,
        zp2: null,
        hycs: null,
        hybs: null,
        xlhbs: null,
        tpname: null,
        rzname: null,
        sfname: null,
        yijian: null,
        branch: null,
        fenyang: null
      },
      // 表单参数
      form: {
        tbGuozhong: {
          chehao: null,
          gysdm: null,
          jshth: null,
        },
        czbh: null,
      },
      // 表单校验
      rules: {
        id: [
          { required: true, message: " 不能为空", trigger: "blur" }
        ],
      },
      printObject: {
        id: 'qwerq',
        popTitle: '玉米检验报告单', // 打印配置页上方的标题
        extraHead: '', // 最上方的头部文字，附加在head标签上的额外标签，使用逗号分割
        preview: false, // 是否启动预览模式，默认是false
        previewTitle: '', // 打印预览的标题
        previewPrintBtnLabel: '预览结束，开始打印', // 打印预览的标题下方的按钮文本，点击可进入打印
        zIndex: 20002, // 预览窗口的z-index，默认是20002，最好比默认值更高
        previewBeforeOpenCallback() {
          console.log('正在加载预览窗口！');
          // console.log(that.msg, this)
        }, // 预览窗口打开之前的callback
        previewOpenCallback() {
          console.log('已经加载完预览窗口，预览打开了！')
        }, // 预览窗口打开时的callback
        beforeOpenCallback() {
          console.log('开始打印之前！')
        }, // 开始打印之前的callback
        openCallback() {
          console.log('执行打印了！')
        }, // 调用打印时的callback
        closeCallback() {
          console.log('关闭了打印工具！' + window.sessionStorage.getItem('czbh'))
          UpdateHuayanDycs(window.sessionStorage.getItem('czbh')).then(response => {
            console.log('修改成功------》')
          })
        }, // 关闭打印的callback(无法区分确认or取消)
        clickMounted() {
          console.log('点击v-print绑定的按钮了！')
        },
        // url: 'http://localhost:8080/', // 打印指定的URL，确保同源策略相同
        // asyncUrl (reslove) {
        //   setTimeout(() => {
        //     reslove('http://localhost:8080/')
        //   }, 2000)
        // },
      }

    };
  },
  created() {
    this.getList();
  },

  methods: {
    /** 查询化验--》列表 */
    getList() {
      this.loading = true;
      listHuayan(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.huayanList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },


    creatQrCode(data) {

      // 清除之前的二维码
      const container = document.getElementById('erweima');
      container.innerHTML = '';

      var qrcode = new QRCode(this.$refs.qrCodeUrl, {
        text: data, // 需要转换为二维码的内容
        width: 90,
        height: 90,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
    },

    generateQRCode() {
      if (!this.text) {
        alert('请输入内容');
        return;
      }
      // 清除之前的二维码
      const container = document.getElementById('qrcode');
      container.innerHTML = '';
      // 生成二维码
      new QRCode(container, {
        text: this.text,
        width: 200,
        height: 200,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      });
    },


    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    previewOpenCallback() {
      console.log('已经加载完预览窗口，预览打开了！')
    },
    // 表单重置
    reset() {
      this.form = {
        tbGuozhong: {
          chehao: null,
          gysdm: null,
          jshth: null,
        },
        czbh: null,
        // id: null,
        // cysj: null,
        // ymqybsm: null,
        // czbh: null,
        // ypks: null,
        // zzks: null,
        // zz: null,
        // zzk: null,
        // sf: null,
        // sfk: null,
        // bwsls: null,
        // bwsl: null,
        // bwslk: null,
        // mbls: null,
        // mbl: null,
        // mblk: null,
        // bnls: null,
        // bnl: null,
        // bnlk: null,
        // szqw: null,
        // zk: null,
        // hysj: null,
        // zt: null,
        // hys: null,
        // czry: null,
        // hwmc: null,
        // bz: null,
        // rzsl: null,
        // rzdj: null,
        // zp1: null,
        // zp2: null,
        // hycs: null,
        // hybs: null,
        // xlhbs: null,
        // tpname: null,
        // rzname: null,
        // sfname: null,
        // yijian: null,
        // branch: null,
        // fenyang: null
      };
      this.tbGuozhongList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {

      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加化验--》";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getHuayan(id).then(response => {
        console.log("from------>");
        this.form = response.data;
        this.tbGuozhongList = response.data.tbGuozhong;
        this.open = true;
        this.title = "玉米检验报告单";
        this.username = this.$store.state.user.name;
        this.shijian = this.form.hysj.substring(0, 10);
        let date = new Date(this.form.tbGuozhong.pzsj);
        let formattedDate = date.toLocaleString('zh-CN', {
          year: 'numeric',
          month: '2-digit',
          day: '2-digit',
          hour: '2-digit',
          minute: '2-digit',
          second: '2-digit',
          hour12: false // 24小时制
        });
        this.form.tbGuozhong.pzsj = formattedDate;
        // let jsonString = JSON.stringify(response.data.tbGuozhong);
        // console.log("from------>" + jsonString);
        window.sessionStorage.setItem("czbh", this.form.czbh);
        setTimeout(() => {
          this.creatQrCode(this.form.czbh);
        }, 1000);
      });

    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.tbGuozhongList = this.tbGuozhongList;
          if (this.form.id != null) {
            updateHuayan(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addHuayan(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除化验--》编号为"' + ids + '"的数据项？').then(function () {
        return delHuayan(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** tb序号 */
    rowTbGuozhongIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** tb添加按钮操作 */
    handleAddTbGuozhong() {
      let obj = {};
      obj.gid = "";
      obj.ddbh = "";
      obj.cardId = "";
      obj.chehao = "";
      obj.wlmcc = "";
      obj.gysbh = "";
      obj.gysdm = "";
      obj.gsmc = "";
      obj.gsbh = "";
      obj.wlbh = "";
      obj.wlmc = "";
      obj.ckbh = "";
      obj.ckmc = "";
      obj.khbh = "";
      obj.songdf = "";
      obj.sdfbh = "";
      obj.shoudf = "";
      obj.jhxm = "";
      obj.mz = "";
      obj.mzsj = "";
      obj.pz = "";
      obj.pzsj = "";
      obj.jz = "";
      obj.hykz = "";
      obj.hyjfkx = "";
      obj.yzkz = "";
      obj.jszl = "";
      obj.yzzl = "";
      obj.jsdj = "";
      obj.jsje = "";
      obj.jlscbz = "";
      obj.yhckrxm = "";
      obj.yhkh = "";
      obj.lxdh = "";
      obj.fpbh = "";
      obj.fpshr = "";
      obj.fpscxxlrsj = "";
      obj.fpscsfzh = "";
      obj.fpsccgbz = "";
      obj.gblx = "";
      obj.gbzt = "";
      obj.hytb = "";
      obj.sgtm = "";
      obj.sby = "";
      obj.xhry = "";
      obj.yj = "";
      obj.tplj = "";
      obj.ddxmbh = "";
      obj.zczm = "";
      obj.zczmtp = "";
      obj.shsfzh = "";
      obj.ddlx = "";
      obj.zcks = "";
      obj.zcmz = "";
      obj.sjxm = "";
      obj.sjdh = "";
      obj.sjsfz = "";
      obj.ymqybsm = "";
      obj.ymqysj = "";
      obj.ymsbm = "";
      obj.ymsbmdy = "";
      obj.xcp = "";
      obj.xcpdy = "";
      obj.zcp = "";
      obj.zcpdy = "";
      obj.hyd = "";
      obj.hyddy = "";
      obj.cmz = "";
      obj.cmzdy = "";
      obj.xcbm = "";
      obj.zjshbs = "";
      obj.shfpbh = "";
      obj.shfpbhdy = "";
      obj.ddwlsl = "";
      obj.rkgbd = "";
      obj.rkgbddy = "";
      obj.ckgbd = "";
      obj.ckgbddy = "";
      obj.ddysdh = "";
      obj.ddyszl = "";
      obj.dbh = "";
      obj.dbh2 = "";
      obj.czymc = "";
      obj.czymc2 = "";
      obj.nlmtbz1 = "";
      obj.nlmtbz2 = "";
      obj.qyry = "";
      obj.jlscsbcs = "";
      obj.jshth = "";
      obj.fpscsbcs = "";
      obj.fpscfhwb = "";
      obj.orclgl = "";
      obj.hysqgch = "";
      obj.ddbdcs = "";
      obj.guige = "";
      obj.sapbzsc = "";
      obj.fzfs = "";
      obj.zds = "";
      obj.zzysdw = "";
      obj.yfrq = "";
      obj.yfk = "";
      obj.bzxx = "";
      obj.dzymkz = "";
      obj.yslx = "";
      obj.cckz = "";
      obj.dzymkdz = "";
      obj.ershisibz = "";
      obj.ycJzcc = "";
      obj.ycCcc = "";
      obj.jctuCp = "";
      obj.jctuHk = "";
      obj.cctuCp = "";
      obj.cctuHk = "";
      obj.bz = "";
      obj.czqztc = "";
      obj.lscp = "";
      obj.lscpBj = "";
      obj.ddysmz = "";
      obj.ddysjz = "";
      obj.ysjzBj = "";
      obj.fkZdr = "";
      obj.sdDwx = "";
      obj.sdBzwmc = "";
      obj.fwZdz = "";
      obj.fwZgz = "";
      obj.fwNwx = "";
      obj.fwBzwm = "";
      obj.kkRjbb = "";
      obj.gbRjbb = "";
      obj.fksj = "";
      obj.clFbbz = "";
      obj.htYcclYcKg = "";
      obj.ysmzBj = "";
      obj.upsapbs = "";
      obj.kksj = "";
      obj.zzmtbs = "";
      obj.thirdCompany = "";
      obj.photoSfz = "";
      obj.yhzhsfzh = "";
      obj.fpph = "";
      obj.hzddybs = "";
      obj.chexc = "";
      obj.zhuanchangbiaoji = "";
      obj.zhuanchangcishu = "";
      obj.photoCkqr = "";
      obj.photoZxcqr = "";
      obj.qymc = "";
      obj.khyh = "";
      obj.yshdwmc = "";
      obj.zzjgdm = "";
      obj.sllx = "";
      obj.photoWtxy = "";
      obj.photoZczm = "";
      obj.photoCbtdht = "";
      obj.photoZt = "";
      this.tbGuozhongList.push(obj);
    },
    /** tb删除按钮操作 */
    handleDeleteTbGuozhong() {
      if (this.checkedTbGuozhong.length == 0) {
        this.$modal.msgError("请先选择要删除的tb数据");
      } else {
        const tbGuozhongList = this.tbGuozhongList;
        const checkedTbGuozhong = this.checkedTbGuozhong;
        this.tbGuozhongList = tbGuozhongList.filter(function (item) {
          return checkedTbGuozhong.indexOf(item.index) == -1
        });
      }
    },
    /** 复选框选中数据 */
    handleTbGuozhongSelectionChange(selection) {
      this.checkedTbGuozhong = selection.map(item => item.index)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/huayan/export', {
        ...this.queryParams
      }, `化验信息_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
